<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        span, #root {
            display: block;
            color: red;
            font-weight: bold;
            font-size: 30px;
            font-style: italic;
            font-family: 黑体, sans-serif;
        }

        #root {
            font-size: 45px;
        }
    </style>
</head>
<body>
<div id="root">
    <span>一小时限时秒杀</span>
    <div id="time"></div>
</div>
<script>
    const root = document.getElementById('root');
    const time = document.getElementById('time');
    let date = new Date();
    date.setHours(date.getHours() + 1);

    function countDown(date) {
        let nowDate = new Date();
        let ss = Math.trunc((date - nowDate) / 1000);
        let time = {
            t: Math.trunc(ss / 3600 % 24),
            m: Math.trunc(ss / 60 % 60),
            s: Math.trunc(ss % 60),
        }
        for (let timeKey in time) {
            if (time[timeKey] < 10)
                time[timeKey] = '0' + time[timeKey];
        }
        if (ss <= 0) return false;
        return time.t + ':' + time.m + ':' + time.s + '\n';
    }

    const Time = setInterval(() => {
        if (countDown(date))
            time.innerHTML = countDown(date);
        else {
            time.innerHTML = '倒计时结束';
            clearInterval(Time);
        }
    }, 1000)

</script>

</body>
</html>